const http = require('http');
const path = require('path');

const express = require('express');
const ecstatic = require('ecstatic');
const history = require('connect-history-api-fallback');
const { createProxyMiddleware } = require('http-proxy-middleware');

const app = express();

app.post('*', (req, res) => {
  res.send('ok');
});


app.use('/v1/', createProxyMiddleware({ target: 'http://192.168.1.158:33000', changeOrigin: true }));
app.use('/ai_arts/api/', createProxyMiddleware({ target: 'http://58.250.250.126:30000', changeOrigin: true }));
app.use('/api/image/', createProxyMiddleware({ target: 'http://192.168.1.199:8070', changeOrigin: true }));
app.use('/api/', createProxyMiddleware({ target: 'http://192.168.1.158:33000', changeOrigin: true }));
app.use('/custom-user-dashboard-backend/', createProxyMiddleware({ target: 'http://192.168.1.211/', changeOrigin: true }));

app.use(history());

app.use(ecstatic({ root: path.join(__dirname, '../dist') }));

http.createServer(app).listen(process.argv[2] || 3084);
    